﻿<?php 
$v_url_back = $_REQUEST['url_back'];
$v_app_code = $_REQUEST['app_code'];
$v_username = $_REQUEST['txt_usename'];
$v_password = $_REQUEST['txt_password'];
if (is_null($v_url_back)) {
	$v_url_back = _CONST_HOMEPAGE_URL_PATH."vn/index.asp";
}

$v_password = md5($v_password);

if (_is_sqlserver()){
	$sql = "Exec ONEGATE_CheckLogin  " ;
	$sql = $sql . "'". $v_username . "'," ;
	$sql = $sql . "'" . $v_password . "'" ;
	$ado_conn->SetFetchMode(ADODB_FETCH_NUMBER);
	$arr_citizen_login = $ado_conn->GetRow($sql);

}

if (sizeof($arr_citizen_login) == 0){?>
	<script>
	alert("Sai tên đăng nhập hoặc mật khẩu");
		window.history.back();
	</script><?php
	exit;
}else{
	// Dang nhap thanh cong
	$citizen_id = $arr_citizen_login[0];
	$citizen_username = $arr_citizen_login[1];
	if (!isset($_SESSION['citizen_id'])){
		$_SESSION['citizen_id'] = $citizen_id;
		$_SESSION['citizen_username'] = $citizen_username;
	}
}
?>
<form action="<?php echo $v_url_back;?>" name="f_back" method="post">
	<!--input type="hidden" name="fuseaction" value="DISPLAY_LOGIN"-->
	<input type="hidden" name="logon_citizen_id" value="<?php echo $citizen_id;?>">
	<input type="hidden" name="logon_citizen_username" value="<?php echo $citizen_username;?>">
	<input type="hidden" name="url_back" value="<?php echo $v_url_back;?>">
</form>		
<script language="javascript">	
	document.forms(0).submit();
</script> 
